package com.lhz.framework.exception;

import com.lhz.common.constant.ResponseState;
import lombok.Getter;

/**
 * token验证异常
 * Created by LiGezZ
 * Date on 2021/4/17 11:07
 *
 * @author lihuazhi
 */
public class ServiceException extends RuntimeException {
    @Getter
    private final Integer code;
    private final String message;

    public ServiceException(ResponseState state) {
        this.code = state.getCode();
        this.message = state.getName();
    }

    public ServiceException(int code, String state) {
        this.code = code;
        this.message = state;
    }

    public ServiceException(String state) {
        this.code = 400;
        this.message = state;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
